package filedemo2;

public class MainDemo1 {
    public static void main(String[] args) {
        java.io.File dir = new java.io.File("C:");
        java.io.FilenameFilter filter = new java.io.FilenameFilter() {
            @Override
            public boolean accept(java.io.File dir, String name) {
                return name.startsWith("b");

            }
        };

        String[] children = dir.list(filter);
        if (children == null) {
            System.out.println("目录不存在或它不是一个目录");
        } else {
            for (int i = 0; i < children.length; i++) {
                String filename = children[i];
                System.out.println(filename);
            }
        }

    }
}
